/* Copyright (c) 2001, Nokia Mobile Phones. All rights reserved */

#ifndef __MSVHANDLER_H__
#define __MSVHANDLER_H__

#include <e32base.h>

class CClientMtmRegistry;
class MMsvObserver;

/*! 
  @class CMsvHandler
  
  @discussion Pure virtual Base class for handling asynchronous message server requests
  */
class CMsvHandler : public CActive, public MMsvSessionObserver
    {
public:
	 // void DeleteEntryL( TMsvId aMsvId );

/*!
  @function ~CMsvHandler
  
  @discussion Destroy the object and release all memory objects
  */
    ~CMsvHandler();

/*!
  @function IsIdle
  
  @discussion Determine whether we are initialised (the CMsvSession can
              be used)
  @result true if we have initialised 
  */
    virtual TBool IsIdle();

protected: // from CActive
/*!
  @function DoCancel
  
  @discussion Cancel any outstanding operation
  */
    void DoCancel();

protected:

/*!
  @function ConstructL
  
  @discussion Perform the second phase construction of a CMsvHandler object
  */
    void ConstructL();

/*!
  @function CMsvHandler
   
  @discussion Perform the first phase of two phase construction
  @param aObserver the object to be used to handle status/error reports
  */
    CMsvHandler(MMsvObserver& aObserver);

/*!
  @function CompleteConstructL

  @discussion Creates client MTM registry when session is ready for use. 
  This completes model construction and is called after 'server
  ready' event is received after async opening of CMsvSession.
  */
    virtual void CompleteConstructL();

/*!
  @function SetMtmEntryL

  @discussion Set the Mtm's current context(entry). Creates an Mtm if we
              haven't already
  @param aEntryId the entry to set
  */
    virtual void SetMtmEntryL(TMsvId aEntryId);

/*!
  @function DeleteEntryL

  @discussion Deletes an entry asynchronously
  @param aMsvEntry the entry to delete
  */
    virtual void DeleteEntryL(TMsvEntry& aMsvEntry);

protected:

/*!
  @var iOperation the currently pending message server operation
  */
    CMsvOperation*  iOperation;

/*!
  @var iSession client session on the message server
  */
    CMsvSession*        iSession;

/*!
  @var iMtm Message Type Module
  */
    CBaseMtm*           iMtm;

/*!
  @var iMtmRegistry Mtm client registry for creating new mtms
  */
    CClientMtmRegistry* iMtmRegistry;

/*!
  @var iObserver Observer to report status/error information
  */
    MMsvObserver&       iObserver;

    };

#endif // __MSVHANDLER_H__

